package practice06;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author Administrator
 * @version V1.0
 * @ProjectName:IntelliJ IDEA
 * @PackageName: practice06
 * @ClassName: practice07.Server
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @date 2020/1/2 9:23
 * @Copyright 大牛版板所有
 */
public class Server {
    Client client = new Client();

    public static void main(String[] args) {
        ServerSocket server = null;
        Socket socket = null;
        DataInputStream dis = null;
        DataOutputStream dos = null;
        try {
            server = new ServerSocket(7000);
            System.out.println("服务端已经启动");
            socket = server.accept();
            dis = new DataInputStream(socket.getInputStream());
            dos = new DataOutputStream(new FileOutputStream("chapter05\\images\\img.jpg"));
            byte[] bytes = new byte[10240];
            int len = 0;
            while ((len = dis.read(bytes)) != -1){
                dos.write(bytes,0,len);
                dos.flush();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void getFile(Client client){

    }
}
